import { ratedApi } from "@/utils/api";

// 受欢迎模块
const ratedModule = {
  namespaced: true,
  state: {
    // 最受欢迎列表数据
    ratedList: [],
  },
  mutations: {
    // 改变最受欢迎列表
    getRatedList(state, payload) {
      state.ratedList = payload.result;
    },
  },
  actions: {
    // 最受欢迎列表请求
    getRatedListAsync({ commit }) {
      return new Promise(async (resolve) => {
        const res = await ratedApi();
        commit("getRatedList", res);
        resolve();
      });
    },
  },
};

export default ratedModule;
